/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentanaMenu.java
 *
 * Created on May 28, 2009, 4:26:19 PM
 */
package ve.edu.ucab.salonesregistro.presentacion;

import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import ve.edu.ucab.salonesregistro.dominio.Salon;

/**
 *
 * @author jonathan
 */
public class VentanaOperaciones extends javax.swing.JFrame {

    private static final long serialVersionUID = -7077206333002700022L;
    private ControlPresentacion control = new ControlPresentacion();
    private String ultimaModificacion = "";

    /** Creates new form VentanaMenu */
    public VentanaOperaciones() {
        initComponents();
        this.popularTabla();
        this.jDateChooser.setDate(new Date());
    }

    public VentanaOperaciones(Integer identificador) {
        initComponents();
        this.popularTabla();
        this.jTextFieldPersona.setText(Integer.toString(identificador));
        this.jDateChooser.setDate(new Date());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        panelSeleccion = new javax.swing.JPanel();
        jTextFieldSalon = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldCapacidad = new javax.swing.JTextField();
        jButtonActualizarSalon = new javax.swing.JButton();
        jButtonEliminarSalon = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jCheckBoxAA = new javax.swing.JCheckBox();
        jCheckBoxVB = new javax.swing.JCheckBox();
        jCheckBoxComputador = new javax.swing.JCheckBox();
        panelAgregar = new javax.swing.JPanel();
        jTextFieldSalon2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldCapacidad2 = new javax.swing.JTextField();
        jButtonLimpiarSalon = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jCheckBoxAA2 = new javax.swing.JCheckBox();
        jCheckBoxVB2 = new javax.swing.JCheckBox();
        jCheckBoxComputador2 = new javax.swing.JCheckBox();
        jLabel7 = new javax.swing.JLabel();
        jButtonAgregarSalon = new javax.swing.JButton();
        panelReserva = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jTextFieldSalon3 = new javax.swing.JTextField();
        jTextFieldPersona = new javax.swing.JTextField();
        jTextFieldReserva = new javax.swing.JTextField();
        jDateChooser = new com.toedter.calendar.JDateChooser();
        jButtonAgregarReserva = new javax.swing.JButton();
        jButtonLimpiarReserva = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Reservas");
        setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Sistema de Reserva"));

        panelSeleccion.setBorder(javax.swing.BorderFactory.createTitledBorder("Salón Seleccionado"));

        jTextFieldSalon.setEditable(false);

        jLabel1.setText("Identificador");

        jLabel2.setText("Capacidad");

        jButtonActualizarSalon.setText("Actualizar");
        jButtonActualizarSalon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonActualizarSalonActionPerformed(evt);
            }
        });

        jButtonEliminarSalon.setText("Eliminar");
        jButtonEliminarSalon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEliminarSalonActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Equipos"));

        jCheckBoxAA.setText("Aire Acondicionado");

        jCheckBoxVB.setText("Video Beam");

        jCheckBoxComputador.setText("Computador");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jCheckBoxAA)
                    .add(jCheckBoxVB)
                    .add(jCheckBoxComputador))
                .addContainerGap(56, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jCheckBoxAA)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jCheckBoxVB)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jCheckBoxComputador)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout panelSeleccionLayout = new org.jdesktop.layout.GroupLayout(panelSeleccion);
        panelSeleccion.setLayout(panelSeleccionLayout);
        panelSeleccionLayout.setHorizontalGroup(
            panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelSeleccionLayout.createSequentialGroup()
                .addContainerGap()
                .add(panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(panelSeleccionLayout.createSequentialGroup()
                        .add(jLabel1)
                        .add(18, 18, 18)
                        .add(panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jTextFieldCapacidad, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                            .add(jTextFieldSalon, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)))
                    .add(jLabel2)
                    .add(panelSeleccionLayout.createSequentialGroup()
                        .add(18, 18, 18)
                        .add(jButtonActualizarSalon)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButtonEliminarSalon, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        panelSeleccionLayout.linkSize(new java.awt.Component[] {jButtonActualizarSalon, jButtonEliminarSalon}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        panelSeleccionLayout.setVerticalGroup(
            panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelSeleccionLayout.createSequentialGroup()
                .add(panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jTextFieldSalon, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(jTextFieldCapacidad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(panelSeleccionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonEliminarSalon)
                    .add(jButtonActualizarSalon))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelAgregar.setBorder(javax.swing.BorderFactory.createTitledBorder("Agregar Salón"));

        jLabel6.setText("Identificador");

        jButtonLimpiarSalon.setText("Limpiar");
        jButtonLimpiarSalon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimpiarSalonActionPerformed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Equipos"));

        jCheckBoxAA2.setText("Aire Acondicionado");

        jCheckBoxVB2.setText("Video Beam");

        jCheckBoxComputador2.setText("Computador");

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jCheckBoxAA2)
                    .add(jCheckBoxVB2)
                    .add(jCheckBoxComputador2))
                .addContainerGap(56, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(jCheckBoxAA2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jCheckBoxVB2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jCheckBoxComputador2)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jLabel7.setText("Capacidad");

        jButtonAgregarSalon.setText("Agregar");
        jButtonAgregarSalon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAgregarSalonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panelAgregarLayout = new org.jdesktop.layout.GroupLayout(panelAgregar);
        panelAgregar.setLayout(panelAgregarLayout);
        panelAgregarLayout.setHorizontalGroup(
            panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelAgregarLayout.createSequentialGroup()
                .addContainerGap()
                .add(panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(panelAgregarLayout.createSequentialGroup()
                        .add(panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel6)
                            .add(jLabel7))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jTextFieldSalon2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                            .add(jTextFieldCapacidad2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)))
                    .add(panelAgregarLayout.createSequentialGroup()
                        .add(18, 18, 18)
                        .add(jButtonLimpiarSalon, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButtonAgregarSalon, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        panelAgregarLayout.linkSize(new java.awt.Component[] {jButtonAgregarSalon, jButtonLimpiarSalon}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        panelAgregarLayout.setVerticalGroup(
            panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelAgregarLayout.createSequentialGroup()
                .add(panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(jTextFieldSalon2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextFieldCapacidad2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel7))
                .add(18, 18, 18)
                .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(panelAgregarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonAgregarSalon)
                    .add(jButtonLimpiarSalon))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        panelReserva.setBorder(javax.swing.BorderFactory.createTitledBorder("Realizar Reserva"));

        jLabel11.setText("Identificador Reserva");

        jLabel13.setText("Clave de Usuario");

        jLabel14.setText("Identificador Salón");

        jTextFieldSalon3.setEditable(false);

        jTextFieldPersona.setEditable(false);

        jButtonAgregarReserva.setText("Agregar");
        jButtonAgregarReserva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAgregarReservaActionPerformed(evt);
            }
        });

        jButtonLimpiarReserva.setText("Limpiar");
        jButtonLimpiarReserva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimpiarReservaActionPerformed(evt);
            }
        });

        jLabel12.setText("Fecha");

        org.jdesktop.layout.GroupLayout panelReservaLayout = new org.jdesktop.layout.GroupLayout(panelReserva);
        panelReserva.setLayout(panelReservaLayout);
        panelReservaLayout.setHorizontalGroup(
            panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelReservaLayout.createSequentialGroup()
                .addContainerGap()
                .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panelReservaLayout.createSequentialGroup()
                        .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel11)
                            .add(jLabel13)
                            .add(jLabel14)
                            .add(jLabel12))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jTextFieldSalon3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                            .add(jTextFieldPersona, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                            .add(jTextFieldReserva, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jDateChooser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, panelReservaLayout.createSequentialGroup()
                        .add(jButtonLimpiarReserva, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButtonAgregarReserva, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        panelReservaLayout.linkSize(new java.awt.Component[] {jButtonAgregarReserva, jButtonLimpiarReserva}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        panelReservaLayout.setVerticalGroup(
            panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelReservaLayout.createSequentialGroup()
                .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel11)
                    .add(jTextFieldReserva, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel13)
                    .add(jTextFieldPersona, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel14)
                    .add(jTextFieldSalon3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jDateChooser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel12))
                .add(18, 18, 18)
                .add(panelReservaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonAgregarReserva)
                    .add(jButtonLimpiarReserva))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Salones"));

        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jTable1.setBackground(new java.awt.Color(231, 237, 246));
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTable1.setSelectionBackground(new java.awt.Color(62, 128, 203));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTable1MouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Información"));

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setRows(5);
        jTextArea1.setText("Universidad Católica Andres Bello\nFacultad de Ingeniería\nEscuela de Informática\nProyecto elaborado para la cátedra de \nSistemas Distribuidos por:\n\n   - Gerardo Barcia\n   - Jonathan Trujillo\n\nCaracas, junio de 2009\n");
        jScrollPane2.setViewportView(jTextArea1);

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2Layout.createSequentialGroup()
                        .add(panelSeleccion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(panelAgregar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(18, 18, 18)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(panelReserva, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2Layout.createSequentialGroup()
                        .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(panelReserva, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(panelSeleccion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(panelAgregar, 0, 312, Short.MAX_VALUE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2Layout.linkSize(new java.awt.Component[] {jPanel1, panelSeleccion}, org.jdesktop.layout.GroupLayout.VERTICAL);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTable1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseReleased
        int row = this.jTable1.getSelectedRow();
        int selectedSalon = (Integer) this.jTable1.getModel().getValueAt(row, 0);
        this.popularCamposSalon(selectedSalon);
    }//GEN-LAST:event_jTable1MouseReleased

    private void jButtonActualizarSalonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonActualizarSalonActionPerformed
        if (this.validarEditar()) {
            int idSalon = Integer.parseInt(this.jTextFieldSalon.getText());
            int capacidad = Integer.parseInt(this.jTextFieldCapacidad.getText());
            boolean vb = this.jCheckBoxVB.isSelected();
            boolean aa = this.jCheckBoxAA.isSelected();
            boolean co = this.jCheckBoxComputador.isSelected();
            boolean resultado = this.control.modificarSalon(idSalon, capacidad, vb, aa, co);
            if (resultado) {
                this.popularTabla();
                JOptionPane.showMessageDialog(null, "Salón modificado con éxito.", "Informacion",
                        JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(null, "Se presentó un error al realizar la operación.", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_jButtonActualizarSalonActionPerformed

    private void jButtonEliminarSalonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEliminarSalonActionPerformed
        if (this.validarEliminar()) {
            int idSalon = Integer.parseInt(this.jTextFieldSalon.getText());
            boolean resultado = this.control.eliminarSalon(idSalon);
            if (resultado) {
                this.popularTabla();
                JOptionPane.showMessageDialog(null, "Salón eliminado con éxito.", "Información",
                        JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(null, "Se presentó un error al realizar la operación.", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_jButtonEliminarSalonActionPerformed

    private void jButtonAgregarSalonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAgregarSalonActionPerformed
        if (this.validarAgregar()) {
            int idSalon = Integer.parseInt(this.jTextFieldSalon2.getText());
            int capacidad = Integer.parseInt(this.jTextFieldCapacidad2.getText());
            boolean vb = this.jCheckBoxVB2.isSelected();
            boolean aa = this.jCheckBoxAA2.isSelected();
            boolean co = this.jCheckBoxComputador2.isSelected();
            boolean resultado = this.control.agregarSalon(idSalon, capacidad, vb, aa, co);
            if (resultado) {
                this.popularTabla();
                JOptionPane.showMessageDialog(null, "Salón agregado con éxito.", "Información",
                        JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(null, "Se presentó un error al realizar la operación.", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_jButtonAgregarSalonActionPerformed

    private void jButtonAgregarReservaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAgregarReservaActionPerformed
        if (validarReservar()) {
            int idSalon = Integer.parseInt(this.jTextFieldSalon3.getText());
            int idReserva = Integer.parseInt(this.jTextFieldReserva.getText());
            int idPersona = Integer.parseInt(this.jTextFieldPersona.getText());
            Date fecha = this.jDateChooser.getDate();
            boolean resultado = this.control.agregarReserva(idReserva, idSalon, idPersona, fecha);
            if (resultado) {
                this.popularTabla();
                JOptionPane.showMessageDialog(null, "Reserva agregada con éxito.", "Información",
                        JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(null, "Se presentó un error al realizar la operación.", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_jButtonAgregarReservaActionPerformed

    private void jButtonLimpiarSalonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimpiarSalonActionPerformed
        this.jTextFieldSalon2.setText("");
        this.jTextFieldCapacidad2.setText("");
        this.jCheckBoxAA2.setSelected(false);
        this.jCheckBoxVB2.setSelected(false);
        this.jCheckBoxComputador2.setSelected(false);
    }//GEN-LAST:event_jButtonLimpiarSalonActionPerformed

    private void jButtonLimpiarReservaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimpiarReservaActionPerformed
        this.jTextFieldReserva.setText("");
        this.jTextFieldPersona.setText("");
//        this.jDateChooser.cleanup();
    }//GEN-LAST:event_jButtonLimpiarReservaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new VentanaOperaciones().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonActualizarSalon;
    private javax.swing.JButton jButtonAgregarReserva;
    private javax.swing.JButton jButtonAgregarSalon;
    private javax.swing.JButton jButtonEliminarSalon;
    private javax.swing.JButton jButtonLimpiarReserva;
    private javax.swing.JButton jButtonLimpiarSalon;
    private javax.swing.JCheckBox jCheckBoxAA;
    private javax.swing.JCheckBox jCheckBoxAA2;
    private javax.swing.JCheckBox jCheckBoxComputador;
    private javax.swing.JCheckBox jCheckBoxComputador2;
    private javax.swing.JCheckBox jCheckBoxVB;
    private javax.swing.JCheckBox jCheckBoxVB2;
    private com.toedter.calendar.JDateChooser jDateChooser;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextFieldCapacidad;
    private javax.swing.JTextField jTextFieldCapacidad2;
    private javax.swing.JTextField jTextFieldPersona;
    private javax.swing.JTextField jTextFieldReserva;
    private javax.swing.JTextField jTextFieldSalon;
    private javax.swing.JTextField jTextFieldSalon2;
    private javax.swing.JTextField jTextFieldSalon3;
    private javax.swing.JPanel panelAgregar;
    private javax.swing.JPanel panelReserva;
    private javax.swing.JPanel panelSeleccion;
    // End of variables declaration//GEN-END:variables

    private void popularTabla() {
        DefaultTableModel dm = new DefaultTableModel();
        dm.addColumn("Identificador");
        dm.addColumn("Capacidad");
        dm.addColumn("Aire Acondicionado");
        dm.addColumn("Video Beam");
        dm.addColumn("Computador");
        ArrayList<Salon> salones = this.control.cosultarSalones();
        for (Salon salon : salones) {
            Vector row = new Vector();
            row.add(salon.getId());
            row.add(salon.getCapacidad());
            row.add(salon.isAireAcondicionado());
            row.add(salon.isVideoBean());
            row.add(salon.isComputador());
            dm.addRow(row);
        }
        this.jTable1.setModel(dm);
    }

    private void popularCamposSalon(int idSalon) {
        Salon salon = this.control.consultarSalon(idSalon);
        this.jTextFieldSalon.setText(Integer.toString(salon.getId()));
        this.jTextFieldSalon3.setText(Integer.toString(salon.getId()));
        this.jTextFieldCapacidad.setText(Integer.toString(salon.getCapacidad()));
        if (salon.isAireAcondicionado()) {
            this.jCheckBoxAA.setSelected(true);
        } else {
            this.jCheckBoxAA.setSelected(false);
        }
        if (salon.isComputador()) {
            this.jCheckBoxComputador.setSelected(true);
        } else {
            this.jCheckBoxComputador.setSelected(false);
        }
        if (salon.isVideoBean()) {
            this.jCheckBoxVB.setSelected(true);
        } else {
            this.jCheckBoxVB.setSelected(false);
        }
    }

    private boolean validarEditar() {
        if (this.jTextFieldSalon.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe seleccionar un salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (this.jTextFieldCapacidad.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar la capacidad del salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (!this.control.validarInt(this.jTextFieldCapacidad.getText())) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar un valor numérico para la capacidad del salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else {
            return true;
        }
    }

    private boolean validarEliminar() {
        if (this.jTextFieldSalon.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe seleccionar un salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else {
            return true;
        }
    }

    private boolean validarAgregar() {
        if (this.jTextFieldSalon2.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar un salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (!this.control.validarInt(this.jTextFieldSalon2.getText())) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar un valor numérico para el salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (this.jTextFieldCapacidad2.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar la capacidad del salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (!this.control.validarInt(this.jTextFieldCapacidad2.getText())) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar un valor numérico para la capacidad del salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else {
            return true;
        }
    }

    private boolean validarReservar() {
        if (this.jTextFieldSalon3.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe seleccionar un salón.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (this.jTextFieldReserva.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar la reserva.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (!this.control.validarInt(this.jTextFieldReserva.getText())) {
            JOptionPane.showMessageDialog(null, "Para realizar esta operación, " +
                    "debe indicar un valor numérico para la reserva.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else {
            return true;
        }
    }
}
